
const Menu = {
  state: {
    menus: [
      
    ],
    activeName: "登录页",
    isCollapse: false,
    historyRoutes:
      sessionStorage.getItem("HISTORY_ROUTES") !== null
        ? JSON.parse(sessionStorage.getItem("HISTORY_ROUTES"))
        : {
            "/": {
              name: "登录页",
              url: "",
              iconCls: "fa fa-plus"
            }
          }
  },
  mutations: {
    //路由路径
    CHANGE_ACTIVE_ROUTE_PATH(state, name) {
      state.activeName = name;
    },
    //改变路由
    CHANGE_HiSTORY_ROUTES(state, routes) {
      state.historyRoutes = routes;
    },
    //改变菜单
    CHANGE_COLLAPSE(state, value) {
      state.isCollapse = !value;
    },
    CHANGE_COLLAPSE_STATE(state,value){
      state.isCollapse = value;
    }
  },
  actions: {
    //点击左侧 添加路由
    addHistoryRoute: (store, params) => {
      let { route, router, self } = params;
      let routes = JSON.parse(sessionStorage.getItem("HISTORY_ROUTES"));
      let IS_REFRESH_RULEGROUP = JSON.parse(
        sessionStorage.getItem("IS_REFRESH_RULEGROUP")
      );

    /*
     route.path ? routes[route.path] = {
        name: route.name,
        path: route.path,
        query: route.query,
        params: route.params
      } : '';
      */
    },
    //关闭删除历史记录
    deleteHistoryRoute: (store, route) => {
      let { tabs, activeName } = route;
      //更新数组
      store.commit("CHANGE_HiSTORY_ROUTES", tabs);
      setTimeout(() => {
        store.commit("CHANGE_ACTIVE_ROUTE_PATH", activeName);
      }, 40);
    },
    //改变菜单状态
    changeCollapse: (store, value) => {
      store.commit("CHANGE_COLLAPSE", value);
    },
    changeCollapseState:(store,value) => {
      store.commit("CHANGE_COLLAPSE_STATE", value);
    }
  },
  getters: {
    sysMenus(state) {
      return state.menus;
    },
    historyRoutes(state) {
      return state.historyRoutes;
    },
    activeName(state) {
      return state.activeName;
    },
    isCollapse(state) {
      return state.isCollapse;
    }
  }
};

export default Menu;



// WEBPACK FOOTER //
// src/store/modules/Menu.js